<template>
<div>
  <t-table
    rowKey="id"
    :data="data"
    :columns="columns"
    hover
    :pagination="pagination"
    :loading="dataLoading"
  >
    <template #name="{row}">
<!--      <t-link @click="dialog.objId=row.id;dialog.header=row.name;dialog.open_review=true" hover="color" theme="primary">{{row.name}}</t-link>-->
      {{row.name}}
    </template>
    <template #copyrightMemberList="{ row }">
      <template v-for="(item,index) in row.copyrightMemberList">
        <a class="t-button-link"  :key="index">{{item.name}}</a>{{(index+1===row.copyrightMemberList.length && row.copyrightCompanyList.length <= 0)?'':'、'}}
      </template>
      <template v-for="(item,index) in row.copyrightCompanyList">
        <a class="t-button-link"  :key="index">{{item.company}}</a>{{index+1===row.copyrightCompanyList.length?'':'、'}}
      </template>
    </template>
    <template #copyrightProjectList="{ row }">
      <template v-for="(item,index) in row.copyrightProjectList">
        <a class="t-button-link"  :key="index">{{item.businessName}}</a>{{index+1===row.copyrightProjectList.length?'':'、'}}
      </template>
    </template>
    <template #getWay="{ row }">
      {{ row.getWay | filterByDict(dict.type.get_way) }}
    </template>
    <template #scopeRights="{ row }">
      {{ row.scopeRights | filterByDict(dict.type.scope_rights, '全部权利') }}
    </template>
<!--    <template #softwareCopyrightStatus="{ row }">-->
<!--      <t-tag @click="dialog.header=row.name;dialog.objId=row.id;dialog.open_approve_list=true" class="cursor-pointer"-->
<!--             :theme="handleTheme(row.softwareCopyrightStatus, dict.type.achievement_status)" variant="light">-->
<!--        {{ row.softwareCopyrightStatus | filterByDict(dict.type.achievement_status) }}-->
<!--      </t-tag>-->
<!--    </template>-->
<!--    <template #op="{ row }">-->
<!--      <t-button size="small"-->
<!--                @click="dialog.objId=row.id;dialog.header=row.name;dialog.open_detail=true"-->
<!--                variant="text" class="t-button-link">-->
<!--        <t-icon name="info-circle" slot="icon"/>-->
<!--        详情-->
<!--      </t-button>-->
<!--    </template>-->
  </t-table>
  <copyright-detail-dialog :objId="dialog.objId" :header="dialog.header" :visible.sync="dialog.open_detail" v-if="dialog.open_detail">

  </copyright-detail-dialog>
  <file-review :header="dialog.header" :projectFileData="projectFileData" :visible.sync="dialog.open_review" v-if="dialog.open_review" :objId="dialog.objId"></file-review>
</div>
</template>

<script>
// import copyrightDetailDialog from "../../../cgzh/copyright/components/copyright-detail-dialog.vue";
import fileReview from "../../../cgzh/components/file-review.vue";

export default {
  name: "copyright-list",
  dicts: ['get_way','scope_rights', 'achievement_status'],
  props: ['deptId', 'idCard'],
  components:{
    // copyrightDetailDialog,
    copyrightDetailDialog: () => import('../../../cgzh/copyright/components/copyright-detail-dialog.vue'),

    fileReview
  },
  data() {
    return {
      projectFileData: [
        {
          id: 1,
          c1: "软件著作权证书",
          c2: "是",
          moduleKey: "copyrightZS",
          fileIds: [],
          fileLists: [],
          require: true,
        },
      ],
      dialog: {
        header: "",
        open: false,
        objId: null,
        open_approve_list: false,
        open_detail: false,
        open_review: false,
      },
      serviceOptions: [],
      projectOptions: [],
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        name: "",
        completeDevelopmentDate: '',
        completeDevelopmentDateRange: [],
        startCompleteDevelopmentDate: '',
        endCompleteDevelopmentDate: '',
        firstPublicationDate: '',
        firstPublicationDateRange: [],
        startFirstPublicationDate: '',
        endFirstPublicationDate: '',
        getWay: '',
        scopeRights: '',
        registerNum: '',
        declareDeptName: '',
        softwareCopyrightStatus: '',
        scopeRightsList: [],
        peopleName: '',
        businessName: '',
        status: "",
        dateRange: [],
        serviceCode: '',
        businessId: null,
        deptId: this.deptId,
        idCard: this.idCard,
      },
      data: [],
      columns: [
        {
          colKey: "name",
          title: "软件名称",
          align: "center"
        },
        // {
        //   colKey: "copyrightName",
        //   title: "著作权人",
        //   align: "center"
        // },
        {
          colKey: "completeDevelopmentDate",
          title: "开发完成日期",
          align: "center"
        },
        {
          colKey: "firstPublicationDate",
          title: "首次发表日期",
          align: "center"
        },
        {
          colKey: "getWay",
          title: "权利取得方式",
          align: "center"
        },
        {
          colKey: "scopeRights",
          title: "权利范围",
          align: "center"
        },
        {
          colKey: "registerNum",
          title: "登记号",
          align: "center"
        },
        // {
        //   colKey: "declareDeptName",
        //   title: "填报单位",
        //   align: "center"
        // },
        {
          colKey: "copyrightMemberList",
          title: "著作权人",
          align: "center"
        },
        {
          colKey: "copyrightProjectList",
          title: "项目来源",
          align: "center"
        },
        // {
        //   colKey: "createTime",
        //   title: "创建时间",
        //   align: "center"
        // },
        // {
        //   colKey: "softwareCopyrightStatus",
        //   title: "软著状态",
        //   align: "center",
        //   fixed: 'right'
        // },
        // {
        //   colKey: "op",
        //   title: "操作",
        //   align: "center",
        //   width: 140,
        // }
      ],
      dataLoading: false,
      pagination: {
        current: 1,
        pageSize: 10,
        total: 0,
        showPageSize: true,
        pageSizeOptions: [10, 20, 30, 50],
        showFirstAndLastPageBtn: false,
        onChange: (pageInfo) => {
          Object.assign(this.pagination, pageInfo)
          this.queryParams.pageNum = pageInfo.current || 1;
          this.queryParams.pageSize = pageInfo.pageSize;
          this.getList()
        },
      },
    };
  },
  created() {
    this.getList();
  },
  methods:{
    getList() {
      if(this.deptId){
        this.dataLoading = true;
        this.$api.cgzh.copyright.list(this.queryParams).then(response => {
          this.data = response.rows;
          this.pagination.total = response.total;
          this.dataLoading = false;
        }).catch((e) => {
          this.dataLoading = false;
          this.$message.error(e.toString());
        });
      }else if(this.idCard){
        this.dataLoading = true;
        this.$api.cgzh.copyright.getJoinList(this.queryParams).then(response => {
          this.data = response.rows;
          this.pagination.total = response.total;
          this.dataLoading = false;
        }).catch((e) => {
          this.dataLoading = false;
          this.$message.error(e.toString());
        });
      }
    },
  }
}
</script>

<style scoped>

</style>
